package com.getpebble.android.framework.protocol.inbound;

import com.getpebble.android.bluetooth.protocol.ProtocolMessage;
import com.getpebble.android.common.core.trace.Trace;
import com.getpebble.android.framework.protocol.EndpointId;
import com.google.common.primitives.UnsignedInteger;
import java.nio.ByteBuffer;

public class PblInboundPingMessage extends PblInboundMessage {
    private final String TAG = getClass().getSimpleName();
    private boolean isIdle;
    private UnsignedInteger mCookie;

    public PblInboundPingMessage(ProtocolMessage message) {
        boolean z = true;
        super(message);
        ByteBuffer buffer = message.getDataBuffer();
        if (buffer.get() != (byte) 1) {
            Trace.error(this.TAG, "Unexpected format.  Not ping?");
        }
        this.mCookie = UnsignedInteger.fromIntBits(buffer.getInt());
        if (buffer.hasRemaining()) {
            if (buffer.get() != (byte) 1) {
                z = false;
            }
            this.isIdle = z;
            return;
        }
        this.isIdle = false;
    }

    public EndpointId getId() {
        return EndpointId.PING;
    }

    protected int getMinSize() {
        return 5;
    }

    public boolean isIdle() {
        return this.isIdle;
    }
}
